from django.http import JsonResponse
from drf_spectacular.utils import extend_schema,inline_serializer
from rest_framework.decorators import action
from rest_framework.mixins import (CreateModelMixin, ListModelMixin,
                                   RetrieveModelMixin)
from utils.mixins import RepairOrderPartVersionUpdateModelMixin as UpdateModelMixin
from rest_framework.viewsets import GenericViewSet
from utils.autoschema import AutoDocSchema, custom_response_serailizer
from utils.decorators import error_response, request_data, activities_logging
from backend.cews.models import RepairOrder, RepairOrderEDoc, RepairOrderPartVersion, StockItem, StockItemEDoc, VersionMaster, Log
from .serializers import (RepairOrderEDocSerializer, RepairOrderPartVersionSerializer, StockItemEDocSerializer, VersionCurrentLatestSerailizer, VersionMasterSerializer)
from rest_framework.response import Response
from django_filters import rest_framework as filters
import django_filters

# class CustomFilter(filters.FilterSet):
#     stock_code = filters.Filter(field_name='stock_code', lookup_expr='exact')
#     class Meta:
#         model = VersionMaster
#         fields = ['stock_code']

class RepairOrderPartVersionViewSet(
    # ListModelMixin,
    RetrieveModelMixin,
    UpdateModelMixin,
    GenericViewSet,
    # CreateModelMixin
):
    serializer_class = RepairOrderPartVersionSerializer
    queryset = RepairOrderPartVersion.objects.select_related('repair_order_part').all()
    # filterset_class = CustomFilter
    # filter_backends = [django_filters.rest_framework.DjangoFilterBackend]
    